package com.kele.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author 赵奥林
 * @date 2021年05月19日 8:02
 * @Description swagger在线文档配置类
 */
@Configuration  //spring的配置文件
@EnableSwagger2  //开启swagger2
public class swaggerConfig {

    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)  //指定版本
                .apiInfo(apiInfo())      //生成api的详细信息
                .useDefaultResponseMessages(false)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.kele.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("可乐用户模块API")
                .description("用户操作及管理模块的controller")
                .version("1.0")
                .contact(new Contact(
                        "赵奥林",
                        "",
                        "3189137314@qq.com"
                ))
                .build();
    }

}
